﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>组织架构管理</title>
    <link href="/Css/global.css" type="text/css" rel="stylesheet" />
    <link href="/Css/admin.css" type="text/css" rel="stylesheet" />
    <link href="/css/m-datepicker.css" type="text/css" rel="stylesheet" />
    <link href="/Scripts/m-treeview/m-treeview.css" type="text/css" rel="stylesheet" />
    <script src="/Scripts/jquery.js" type="text/javascript"></script>
    <script src="/Scripts/common.js" type="text/javascript"></script>
    <script src="/Scripts/m-lhgdialog/m-lhgdialog.js" type="text/javascript"></script>
    <script src="/Scripts/m-treeview/m-treeview.js" type="text/javascript"></script>
</head>
<body>
    <table>
        <tr>
            <td>
                <ul id="checkBoxTree1" class="filetree">
                </ul>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        $.ajax({
            url: "/department/GetChildDepartment?rd=" + new Date(),
            type: "get",
            success: function (data) {
                $("#checkBoxTree1").treeview({
                    type: "radio", 						//类型，默认情况下是文字，值分别有：normal/checkbox/radio
                    collapsed: false, 					//是否默认收紧，true为收紧，false为展开
                    unique: false, 						//是否只允许打开一个一级节点，true为是，false为否
                    radioCallBack: function (treeNode) {		//点击radio时的回调函数
                        //console.log(treeNode);			//treeNode当前点击的radio或checkbox的JQ对象

                        var size = parseInt(treeNode.parent().children('ul').children('li').size()) + 1;
                        var nodeidDB = treeNode.attr("nodeid") + "-" + size;

                        // 给父窗口新增编辑组织架构赋值
                        var id = treeNode.val();
                        var parentDepartment = $(window.top.oSWin.document.getElementById('parentID'));
                        if (parentDepartment.val() != undefined) {
                            parentDepartment.val(id);
                        }
                        else {
                            $(window.top.oSWin.document.getElementById('DepartmentID')).val(id);
                        }
                        // 将部门名称赋值给父窗口元素
                        $(window.top.oSWin.document.getElementById('departmentName')).html(treeNode.next().text());

                        var departmentID = '<%=ViewData["DepartmentID"] %>';
                        if (departmentID != '') {
                            // 保存部门id等级值
                            var level = $(window.top.oSWin.document.getElementById('level'))
                            if (level != undefined) {
                                level.val(nodeidDB);
                            }
                        }
                        // 关闭当前窗口
                        window.top.oSDG.cancel();

                    },
                    nodeCallBack: function (treeNode) {

                    },
                    json: data

                });
                // 树加载完成后赋值
                $('#tvNode_<%=ViewData["DepartmentID"] %>').attr("checked", true);
            }
        });
    </script>
</body>
</html>
